package scc.project.entity.vo;

/**
 * 使用 RestFul 的翻页Vo 对象
 *
 * @author 陈圳佳
 *         日期：2015/6/22
 */
public class RestFulPageVo<T> extends PageVo<T> {
    /**
     * URl 的后缀
     */
    private String urlSuffix;

    public RestFulPageVo(int pageNum, String urlSuffix) {
        super(pageNum);
        this.urlSuffix = urlSuffix;
    }

    public String getUrl(long num) {
        return num + urlSuffix + joinParams();
    }

    public static <T> RestFulPageVo<T> convert(PageVo<T> pageVo, String suffix) {
        if (pageVo == null) return null;
        RestFulPageVo<T> restFulPageVo = new RestFulPageVo<T>(pageVo.getPageNum(), suffix);
        restFulPageVo.setData(pageVo.getData()).setTotal(pageVo.getTotal()).setRows(pageVo.getRows()).setOffset(pageVo.getOffset()).setParams(pageVo.getParams());
        return restFulPageVo;
    }
}
